﻿#region Copyright (C) Sector7 Software Studio. All rights reserved
/*******************************************************************************************
 * Creation
 *      Author:         Wolf Lai
 *      Date:           2013/5/28 星期二 21:11:01
 *      Version:        
 * Modification 
 *      Author: 
 *      Date: 
 *      Description: 
 *      Version:
 *******************************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Sector7.Framework.DB;
using Sector7.Medical.EntityType;
using System.Collections;
using Sector7.Medical.Consts;

namespace Sector7.Medical.DAO.Standard
{
    /// <summary>
    /// 采购单项数据访问对象
    /// </summary>
    public class PurchasesBillItemDAO : DAOBase<M7_PurchasesBillItem>, IPurchasesBillItemDAO
    {
        #region Public functions

        public int Create(List<M7_PurchasesBillItem> items)
        {
            string sql = string.Format(@"
                INSERT INTO {0}
                        ({1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11})
                    VALUES
                        (@{1}, @{2}, @{3}, @{4}, @{5}, @{6}, @{7}, @{8}, @{9}, @{10}, @{11})",
                C_M7_TableName.PURCHASES_BILL_ITEM,
                C_ColumnName.BILL_ID,
                C_ColumnName.DRUG_ID,
                C_ColumnName.SPEC_ID,
                C_ColumnName.UNIT_ID,
                C_ColumnName.NUMBER,
                C_ColumnName.PURCHASES_PRICE,
                C_ColumnName.SALES_PRICE,
                C_ColumnName.BATCH_NUMBER,
                C_ColumnName.LOT_NUMBER,
                C_ColumnName.PRODUCED_DATE,
                C_ColumnName.AVAILABLE_DATE);

            using (DBHelper helper = new DBHelper())
            {
                return helper.ExecuteBatchNonQuery(sql,
                    items,
                    C_ColumnName.BILL_ID,
                    C_ColumnName.DRUG_ID,
                    C_ColumnName.SPEC_ID,
                    C_ColumnName.UNIT_ID,
                    C_ColumnName.NUMBER,
                    C_ColumnName.PURCHASES_PRICE,
                    C_ColumnName.SALES_PRICE,
                    C_ColumnName.BATCH_NUMBER,
                    C_ColumnName.LOT_NUMBER,
                    C_ColumnName.PRODUCED_DATE,
                    C_ColumnName.AVAILABLE_DATE);
            }
        }
        
        #endregion

        #region Structure

        public PurchasesBillItemDAO()
        {
            m_tableName = C_M7_TableName.PURCHASES_BILL_ITEM;
            m_primaryKeyName = C_ColumnName.ITEM_ID;
        }

        #endregion
    }
}
